const express = require("express");
const exApp = require("../index");
const router = express.Router();
const mysql = require("../connect/pomsql");
// zyb优惠券明细管理添加
function Fun() {
  var date = new Date();
  return date.toISOString().slice(0, 19).replace("T", " ");
}
router.post("/addGoods", async function (req, res) {
  const { imgs, title, price, own, type, direction, tabs } = req.body;
  let create_time = Fun(),
    updata_up = Fun();
  let sql = `insert into products (imgs,title,price,own,type,direction,create_time,updata_up,tabs) values('${imgs}', '${title}', '${price}', '${own}',  '${type}',  '${direction}',  '${create_time}',  '${updata_up}', '${tabs}')`;
  let data = await mysql(sql);
  res.json({
    code: 200,
    data,
  });
});
router.post("/addTheme", async function (req, res) {
  const { imgs, title, own, direction, tabs } = req.body;
  let create_time = Fun(),
    updata_up = Fun();
  let sql = `insert into theme (imgs,title,own,direction,create_time,updata_up,tabs) values('${imgs}', '${title}', '${own}',  '${direction}',  '${create_time}',  '${updata_up}', '${tabs}')`;
  let data = await mysql(sql);
  res.json({
    code: 200,
    data,
  });
});

exApp.use("/", router);
